package com.douqu.game.core.entity.world;

import com.bean.core.buffer.ByteBuffer;

/**
 *
 * Created by data on 2017/9/27.
 */
public class WorldArenaBean {

    private int rank;
    private  String objectIndex = "";
    private boolean isBattle;

    public WorldArenaBean() {
    }

    public WorldArenaBean(String objectIndex) {
        this.objectIndex = objectIndex;
    }

    public WorldArenaBean(WorldArenaBean worldArenaBean)
    {
        this.rank = worldArenaBean.rank;
        this.objectIndex = worldArenaBean.objectIndex;
    }

    public void writeTo(ByteBuffer buffer)
    {
        buffer.writeShort(rank);
        buffer.writeUTF(objectIndex);
    }


    public void loadFrom(ByteBuffer buffer)
    {
        rank = buffer.readShort();
        objectIndex = buffer.readUTF();
    }



    public void setRank(int rank) {
        this.rank = rank;
    }

    public int getRank() {
        return rank;
    }

    public String getObjectIndex() {
        return objectIndex;
    }

    public void setObjectIndex(String objectIndex) {
        this.objectIndex = objectIndex;
    }

    public boolean isBattle() {
        return isBattle;
    }

    public void setBattle(boolean isBattle) {
        this.isBattle = isBattle;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof WorldArenaBean)) return false;

        WorldArenaBean rank = (WorldArenaBean) o;

        if (objectIndex != null ? !objectIndex.equals(rank.objectIndex) : rank.objectIndex != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return objectIndex != null ? objectIndex.hashCode() : 0;
    }

    /**
     * objectIndex相同认为时同一个
     */


    @Override
    public String toString() {
        return "{" +
                "rank=" + rank +
                ", objectIndex='" + objectIndex + '\'' +
                '}';
    }
}
